
<!doctype html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Twitter“点赞”红心按钮CSS3动画特效</title>
	<style>
		body{color: #333333;}
    #container{
    	margin:0 auto;
    	width: 900px;
    	font-family: arial;
    }
    #container h3{font-family: "Microsoft YaHei";}
    .heart {
	    background: url(img/web_heart_animation.png);
	    background-position: left;
	    background-repeat: no-repeat;
	    height: 50px;
	    width: 50px;
	    cursor: pointer;
	    position: absolute;
	    left:-14px;
        background-size:2900%;
    }
    .heart:hover, .heart:focus{
    background-position: right;
	}

    @-webkit-keyframes heartBlast {
    0% {
	    background-position: left;
	}
	100% {
	    background-position: right;
	}
	}

	@keyframes heartBlast {
	    0% {
	    background-position: left;
	}
	100% {
	    background-position: right;
	}
	}

	.heartAnimation {
    display: inline-block;
    -webkit-animation-name: heartBlast;
    animation-name: heartBlast;
    -webkit-animation-duration: .8s;
    animation-duration: .8s;
    -webkit-animation-iteration-count: 1;
    animation-iteration-count: 1;
    -webkit-animation-timing-function: steps(28);
    animation-timing-function: steps(28);
    background-position: right;
    }
    .feed p{font-family: "Microsoft YaHei",'Georgia', Times, Times New Roman, serif; font-size: 25px;}
    .feed{clear: both; margin-bottom: :20px; height: 150px; position: relative;}
    a{color: #7ac9ed;}
    p{margin: 0px; padding: 0px;}
    .likeCount{font-family: 'Georgia', Times, Times New Roman, serif; margin-top: 32px;margin-left: 68px;font-size: 25px;color: #999999}
	</style>
</head>
<body>
	<article class="htmleaf-container">
		<header class="htmleaf-header">
			<h1>Twitter“点赞”红心按钮CSS3动画特效 <span>Twitter Heart Button CSS3 Animation</span></h1>
			<div class="htmleaf-links">
				<a class="htmleaf-icon icon-htmleaf-home-outline" href="http://down.admin5.com" title="A5源码" target="_blank"><span> A5源码</span></a>
				<a class="htmleaf-icon icon-htmleaf-arrow-forward-outline" href="http://down.admin5.com" title="返回下载页" target="_blank"><span> 返回下载页</span></a>
			</div>
		</header>
		<div id="container">
			<h3>点击下面的红心查看效果！</h3>

			<div class="feed" id="feed1">
			<p>JS特效 <a href="http://down.admin5.com/texiao/" target="_blank">http://down.admin5.com/texiao//</a></p>
			<div class="heart " id="like1" rel="like"></div> <div class="likeCount" id="likeCount1">14</div>
			</div>

			<div class="feed" id="feed2">
			<p>百度一下 <a href="https://www.baidu.com/" target="_blank">https://www.baidu.com</a></p>
			<div class="heart" id="like2" rel="like"></div> <div class="likeCount" id="likeCount2">10</div>
			</div>

			<div class="feed" id="feed2">
			<p>A5源码 <a href="http://down.admin5.com" target="_blank">http://down.admin5.com</a></p>
			<div class="heart" id="like3" rel="like"></div> <div class="likeCount" id="likeCount3">24</div>


		</div>
	
	</article>
	<script src="http://libs.useso.com/js/jquery/1.11.0/jquery.min.js" type="text/javascript"></script>
	<script>window.jQuery || document.write('<script src="js/jquery-1.11.0.min.js"><\/script>')</script>
	<script>
	$(document).ready(function()
	{
    
	$('body').on("click",'.heart',function()
    {
    	
    	var A=$(this).attr("id");
    	var B=A.split("like");
        var messageID=B[1];
        var C=parseInt($("#likeCount"+messageID).html());
    	$(this).css("background-position","")
        var D=$(this).attr("rel");
       
        if(D === 'like') 
        {      
        $("#likeCount"+messageID).html(C+1);
        $(this).addClass("heartAnimation").attr("rel","unlike");
        
        }
        else
        {
        $("#likeCount"+messageID).html(C-1);
        $(this).removeClass("heartAnimation").attr("rel","like");
        $(this).css("background-position","left");
        }


    });


	});
	</script>
</body>
</html>